#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "cppobject.h"

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    // 使用qmlRegisterType注册C++类型至QML
    // 参数1: import时模块名
    // 参数2: 主版本号
    // 参数3: 次版本号
    // 参数4: QML类型名
    qmlRegisterType<CppObject>("MyCppObject", 1, 0, "CppObject");

    QQmlApplicationEngine engine;

    // 也可以注册为qml全局对象
    // engine.rootContext()->setContextProperty("cppObj", new CppObject);

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
